﻿using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mojito.Entity;

namespace UT_WebAPI
{
    [TestClass]
    public class UtDishCategoryAPI
    {
        private string addedDishCategoryID;
        private string addedDishCategoryName;

        [TestMethod]
        public void TestAdd01()
        {
            const string dishCategoryName = "TestCategory01";
            using (var response = TestUtility.SendAsync(HttpMethod.Post, "http://localhost/api/DishCategoryAPI/Add/" + dishCategoryName))
            {
                Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);

                var responseContent = response.Content.ReadAsStringAsync().Result;
                addedDishCategoryID = responseContent;
                addedDishCategoryName = dishCategoryName;
            }
        }

        [TestMethod]
        public void TestAdd02()
        {
            const string dishCategoryName = "TestCategory02";
            using (var response = TestUtility.SendAsync(HttpMethod.Post, "http://localhost/api/DishCategoryAPI/Add/" + dishCategoryName))
            {
                Assert.AreEqual(HttpStatusCode.NotModified, response.StatusCode);
            }
        }

        [TestMethod]
        public void TestGet01()
        {
            using (var response = TestUtility.SendAsync(HttpMethod.Get, "http://localhost/api/DishCategoryAPI/Get/"))
            {
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }
        }

    }
}
